<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <?php include_http_metas() ?>
    <?php include_metas() ?>
    <?php include_title() ?>
    <?php include_stylesheets() ?>
    <?php echo javascript_include_tag('lib/jquery-1.3.2.min.js') ?>
      <!--[if IE]><?php echo javascript_include_tag('lib/flot/excanvas.pack.js') ?><![endif]-->
    <?php echo javascript_include_tag('lib/flot/jquery.flot.min.js') ?>
    <?php echo javascript_include_tag('lib/flot/jquery.flot.stack.min.js') ?>

    <link href="<?php echo image_path('rbisui/icon.png'); ?>" rel="shortcut icon"  />
  </head>


  <body>
    <script type="text/javascript">
      // Important variables for the whole application
      var toggledVertical =false;
      var toggledHorizontal =true;
      var generateReport_request;
      var newPlot=false;
      var plot;


      function generateStats(){
        //if theres no plot already
        //if(plot==undefined){
          var generateStatistics_handler = new XHRHandler();
          loadAndShow(
            generateStatistics_handler,
            {
              'speciesList[]': selectedItems
            },
            '<?php echo url_for('report/statistics') ?>',
            'statistics-content',
            'statistics-loader'
          ); //End of Statistics
        /* } else{
          //just redraw the plot
          plot.setupGrid();
          plot.draw();
        }
        */

      }
      function showSlidingDiv(){
        toggledVertical = !toggledVertical;
        $("#dialog").animate({"height": "toggle"}, { duration: 1000 });
        $("#backtabs").animate({"height": "toggle"}, { duration: 1000 });
        updatePositionVerticalControl(toggledVertical,toggledHorizontal);

        if(selectedItems!=undefined && selectedItems.length>0 && toggledVertical){
          //Generate Statistics
          if(newPlot){
            setTimeout("generateStats()", 500);
            newPlot=false;
          }
          
        }
      }

      function showSlidingSideDiv3(){
        toggledHorizontal = !toggledHorizontal;
        $("#sidebar").animate({"width": "toggle"}, { duration: 1000 });
        $("#navbarright").animate({"hide": "toggle"}, { duration: 0});
        $("#statistics").animate({"width": "-=400px"}, { duration: 1000});
        $("#chart").animate({"width": "-=400px"}, { duration: 1000});
        updatePositionHorizontalControl(toggledVertical, toggledHorizontal);

        if(selectedItems!=undefined && selectedItems.length>0 && toggledVertical){
          //Generate Statistics
          setTimeout("generateStats()", 500);

        }
      }

      function showSlidingSideDiv2(){
        toggledHorizontal = !toggledHorizontal;
        $("#sidebar").animate({"width": "toggle"}, { duration: 1000 });
        $("#navbarright").animate({"hide": "toggle"}, { duration: 0});
        $("#statistics").animate({"width": "100%"}, { duration: 1000});
        $("#chart").animate({"width": "100%"}, { duration: 1000});
        updatePositionHorizontalControl(toggledVertical, toggledHorizontal);


        if(selectedItems!=undefined && selectedItems.length>0 && toggledVertical){
          //Generate Statistics
          setTimeout("generateStats()", 500);
        }
      }
      //]]>
    </script>

    <?php include('topMenu.php') ?>


    <div id="content">
      <?php include('map.php')?>
      <?php include('dialog.php') ?>
      <?php include('sidebar.php') ?>
    </div>
    <div id="footer">
      <ul>

        <li class="credit"><a href="http://www.kaust.edu.sa"><img  src="<?php echo image_path('rbisui/text2176.png'); ?>"/></a></li>
        <li id="loadingauto"><div id="xmlfile">
            <div id="xmlfile-loader" class="loader">
              <?php echo __("Generating") ?> <?php echo __("XML File...") ?>
              <img alt="loader" id="loader-img" src="<?php echo image_path('ajax-loader-small.gif');?>"/>
            </div>
            <div id="gmarkers-loader" class="loader">
              <?php echo __("Generating") ?> <?php echo __("GMarkers...") ?>
              <img alt="loader" id="loader-img" src="<?php echo image_path('ajax-loader-small.gif');?>"/>
            </div>
          </div></li>
        <li id="language"><?php include_component('language', 'language'); ?></li>
        <li><select name="Year" >
            <option>2008</option>
            <option>All</option>
          </select></li>

      </ul>

    </div>
    <?php if ($_SERVER['SERVER_NAME']=="rbis.almacode.com") { ?>
    <!-- Google Analytics -->
    <script type="text/javascript">
      var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
      document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
      try {
        var pageTracker = _gat._getTracker("UA-11622978-2");
        pageTracker._setDomainName(".rbis.almacode.com");
        pageTracker._trackPageview();
      } catch(err) {}
    </script>
      <?php } ?>
    <?php include_javascripts() ?>

    <script src="<?php echo javascript_path('bonusquery.js').'?'.filemtime($_SERVER['DOCUMENT_ROOT'].javascript_path('bonusquery.js')) ?>" type="text/javascript"></script>

    <script src="<?php echo javascript_path('statistics.js').'?'.filemtime($_SERVER['DOCUMENT_ROOT'].javascript_path('statistics.js')) ?>" type="text/javascript"></script>

  </body>
</html>